const fs = require("fs");
const path = require("path");

fs.readFile(path.join(__dirname, "public/index.html"), (err, data) => {
  if (err) {
    console.error(err);
    return;
  } else {
    const str1 = data.toString();
    console.log(str1);
    const str2 = str1.replace(/[\r\n]/g, "");
    fs.writeFile(path.join(__dirname, "dist/index.html"), str2, (err) => {
      if (err) {
        console.error(err);
        return;
      } else {
        console.log("build success");
      }
    });
  }
});
